const express = require('express')
const multer = require('multer')
const path = require('path')
const cors = require('cors')
const app = express();

const uploadDir = path.join(__dirname, 'uploads')
const upload = multer({ dest: uploadDir })


app.use(cors())
app.post('/upload', upload.single('file'), (req, res) => {
  if (!req.file) {
    return res.status(400).send('No files ')
  }
  res.send("File uploaded successfully.")
})
app.listen(4000, () => {
  console.log('service started on http://localhost:4000')
})
